package tests;

import java.sql.Date;

import junit.framework.Assert;

import org.junit.BeforeClass;
import org.junit.Test;

import entities.FinancialInfo;
import entities.Student;
import entities.Student.education;
import entities.Student.maritalStatuses;

public class TestChangeStudentInformation {
	private static Student student;

	@BeforeClass
	public static void startup() {
		student = new Student(0, "123");

	}

	@Test
	public void testChangeAdress() {
		student.setAddress("123 abc");
		Assert.assertTrue(student.getAddress() == "123 abc");
		student.setAddress("321 cba");
		Assert.assertTrue(student.getAddress() == "321 cba");
	}

	@Test
	public void testChangeBirthDay() {
		Date birthday_date = new Date(01, 01, 1990);
		student.setBirthdate(birthday_date);
		Assert.assertTrue(student.getBirthdate() == birthday_date);
		Date new_birthday_date = new Date(10, 10, 1999);
		student.setBirthdate(new_birthday_date);
		Assert.assertTrue(student.getBirthdate() == new_birthday_date);

	}

	@Test
	public void testChangeCitizenship() {
		student.setCitizenship(true);
		Assert.assertTrue(student.getIsCitizen() == true);
		student.setCitizenship(false);
		Assert.assertTrue(student.getIsCitizen() == false);
	}

	@Test
	public void testChangeEmail() {
		student.setEmail("123@abc.com");
		Assert.assertTrue(student.getEmail() == "123@abc.com");
		student.setEmail("abc@123.com");
		Assert.assertTrue(student.getEmail() == "abc@123.com");
	}

	@Test
	public void testChangeFatherEducation() {
		student.setFatherEducation(education.DEGREE);
		Assert.assertTrue(student.getFatherEducation() == education.DEGREE);
		student.setFatherEducation(education.DIPLOMA);
		Assert.assertTrue(student.getFatherEducation() == education.DIPLOMA);

	}

	@Test
	public void testChangeFinancialInfo() {
		FinancialInfo finances_to_set = new FinancialInfo();
		finances_to_set.setChildSupport(0);
		finances_to_set.setHouseholdIncome(0);
		finances_to_set.setMonthlyExpenses(0);
		finances_to_set.setPersonalIncome(0);
		finances_to_set.setScholarship(0);
		finances_to_set.setTaxableEarnings(0);
		student.setFinances(finances_to_set);

		Assert.assertTrue(student.getFinances() == finances_to_set);
		FinancialInfo finances_to_reset = new FinancialInfo();
		finances_to_reset.setChildSupport(1);
		finances_to_reset.setHouseholdIncome(1);
		finances_to_reset.setMonthlyExpenses(1);
		finances_to_reset.setPersonalIncome(1);
		finances_to_reset.setScholarship(1);
		finances_to_reset.setTaxableEarnings(1);
		student.setFinances(finances_to_reset);
		// should be an error here
		Assert.assertTrue(student.getFinances() == finances_to_reset);

	}

	@Test
	public void testChangeInstitution() {
		student.setInstitution("abc University");
		Assert.assertTrue(student.getInstitution() == "abc University");
		student.setInstitution("cba University");
		Assert.assertTrue(student.getInstitution() == "cba University");
	}

	@Test
	public void testChangeMaritalStatuses() {
		student.setMaritalStatus(maritalStatuses.SINGLE);
		Assert.assertTrue(student.getMaritalStatus() == maritalStatuses.SINGLE);
		student.setMaritalStatus(maritalStatuses.MARRIED);
		Assert.assertTrue(student.getMaritalStatus() == maritalStatuses.MARRIED);
	}

	@Test
	public void testChangeMotherEducation() {
		student.setMotherEducation(education.DEGREE);
		Assert.assertTrue(student.getMotherEducation() == education.DEGREE);
		student.setMotherEducation(education.DIPLOMA);
		Assert.assertTrue(student.getMotherEducation() == education.DIPLOMA);
	}

	@Test
	public void testChangeName() {
		student.setName("Abc");
		Assert.assertTrue(student.getName() == "Abc");
		student.setName("Cba");
		Assert.assertTrue(student.getName() == "Cba");

	}

	@Test
	public void testChangePhoneNumber() {
		student.setPhoneNumber("306 123");
		Assert.assertTrue(student.getPhoneNumber() == "306 123");
		student.setPhoneNumber("306 321");
		Assert.assertTrue(student.getPhoneNumber() == "306 321");

	}

	@Test
	public void testChangeSIN() {
		student.setSIN("123456789");
		Assert.assertTrue(student.getSIN() == "123456789");
		student.setSIN("987654321");
		Assert.assertTrue(student.getSIN() == "987654321");
	}

}